import { Component, OnInit, ViewEncapsulation } from "@angular/core";
import { StockTopBarService, ACTION_SET_BAR_TYPE, ACTION_ITEM_CLICK } from "./stock-top-bar.service";
import { DISPLAY_STRATEGY_REPLACE, } from "tab-list";

@Component({
  // moduleId: module.id,
  selector: "stock-top-bar",
  templateUrl: "stock-top-bar.component.html",
  encapsulation: ViewEncapsulation.None,
  styleUrls: [
    "stock-top-bar.component.less"
  ]
})
export class StockTopBarComponent implements OnInit {

  methodList = [
    {
      text: "",
      textStrategy: DISPLAY_STRATEGY_REPLACE,
      children: [
        {
          text: "前复权",
          method: "re"
        },
        {
          text: "后复权",
          method: "ex"
        },
      ]
    }
  ];

  constructor(private service: StockTopBarService) { }

  onTabClick(tab) {
    this.service.source.next({
      type: ACTION_ITEM_CLICK,
      payload: tab
    });
  }

  setMethod(method) {
    console.debug("SET METHOD: ", method);
    this.service.method = method;
  }
  ngOnInit() {
  }

}